//package com.wejoy.video.middle.station.api.controller.screen;
//
//import com.alibaba.fastjson2.JSONArray;
//import com.alibaba.fastjson2.JSONObject;
//import com.baidubce.http.HttpMethodName;
//import com.wejoy.video.middle.station.api.annotation.SignatureAuth;
//import com.wejoy.video.middle.station.api.controller.BaseController;
//import com.wejoy.video.middle.station.data.constant.BaiduEVSConstant;
//import com.wejoy.video.middle.station.data.constant.RedisKeys;
//import com.wejoy.video.middle.station.data.domain.PageResult;
//import com.wejoy.video.middle.station.data.domain.system.*;
//import com.wejoy.video.middle.station.data.domain.workorder.OrderPhotoLib;
//import com.wejoy.video.middle.station.data.domain.workorder.WorkOrderInfo;
//import com.wejoy.video.middle.station.data.domain.workorder.WorkOrderProcess;
//import com.wejoy.video.middle.station.data.domain.workorder.WorkOrderReview;
//import com.wejoy.video.middle.station.data.enums.dict.EnumBigScreen;
//import com.wejoy.video.middle.station.data.enums.dict.EnumDeptType;
//import com.wejoy.video.middle.station.data.enums.dict.EnumWorkOrderStatus;
//import com.wejoy.video.middle.station.data.service.evs.IEvsHttpService;
//import com.wejoy.video.middle.station.data.service.system.ISysCarmeraService;
//import com.wejoy.video.middle.station.data.service.system.ISysDeptService;
//import com.wejoy.video.middle.station.data.service.system.ISysDeptVideoService;
//import com.wejoy.video.middle.station.data.service.workorder.IOrderPhotoLibService;
//import com.wejoy.video.middle.station.data.service.workorder.IWorkOrderInfoService;
//import com.wejoy.video.middle.station.data.service.workorder.IWorkOrderProcessService;
//import com.wejoy.video.middle.station.data.service.workorder.IWorkOrderReviewService;
//import com.wejoy.video.middle.station.data.util.StringUtils;
//import com.wejoy.video.middle.station.data.util.WJAssert;
//import com.wejoy.video.middle.station.data.util.baiduevs.BaiduRequestSignatureHaders;
//import com.wejoy.video.middle.station.data.util.baiduevs.HttpResult;
//import com.wejoy.video.middle.station.data.vo.RespJSON;
//import com.wejoy.video.middle.station.data.vo.ReturnCode;
//import com.wejoy.video.middle.station.data.vo.api.AlarmsOrCameraVO;
//import com.wejoy.video.middle.station.data.vo.api.BusinessOverbiewVO;
//import com.wejoy.video.middle.station.data.vo.api.CenterAlarmsVO;
//import com.wejoy.video.middle.station.data.vo.api.DeptNode;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.util.CollectionUtils;
//import org.springframework.util.ObjectUtils;
//import org.springframework.web.bind.annotation.*;
//
//import java.io.IOException;
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Optional;
//import java.util.stream.Collectors;
//
///**
// * @Author miracle_j
// * Create by 2024/4/2 7:01 PM
// */
//@RestController
//@RequestMapping("/api")
//public class ApiV2ScreenAction extends BaseController {
//    @Autowired
//    private IEvsHttpService evsHttpService;
//    @Autowired
//    private ISysDeptVideoService sysDeptVideoService;
//    @Autowired
//    private RedisTemplate redisTemplate;
//    @Autowired
//    private IWorkOrderInfoService workOrderInfoService;
//    @Autowired
//    private IWorkOrderProcessService workOrderProcessService;
//    @Autowired
//    private IWorkOrderReviewService workOrderReviewService;
//    @Autowired
//    private IOrderPhotoLibService orderPhotoLibService;
//    @Autowired
//    private ISysDeptService sysDeptService;
//    @Autowired
//    private ISysCarmeraService sysCarmeraService;
//    /**
//     * 获取部门树
//     * @return
//     * @throws IOException
//     */
//    @ResponseBody
//    @RequestMapping("/getDeptTree")
//    public RespJSON getDeptTree(@RequestBody SysDept req){
//        SysDept evsApiDept = new SysDept();
//        evsApiDept.setParentId(-1);
//        evsApiDept.setIncludeLower(true);
//        List<DeptNode> data = sysDeptService.convertToDesiredFormat(evsHttpService.getDepartmentsJson(evsApiDept, evsHttpService.getToken()));
//        List<SysDept> list = sysDeptService.getList(new SysDept());
//        data.forEach(item->{
//            Optional<SysDept> first = list.stream()
//                    .filter(de -> de.getId()==item.getId())
//                    .findFirst();
//            if(first.isPresent()){
//                SysDept sysDept = first.get();
//                item.setAlarmsCount(sysDept.getAlarmsCount());
//                item.setPoiId(sysDept.getPoiId());
//                item.setPoiName(sysDept.getPoiName());
//                item.setDescribes(sysDept.getDescribes());
//                item.setAiCameraCount(sysDept.getAiCameraCount());
//                item.setCameraCount(sysDept.getCameraCount());
//                item.setUserId(sysDept.getUserId());
//                item.setDeptType(sysDept.getDeptType());
//                item.setLatitude(sysDept.getLatitude());
//                item.setLongitude(sysDept.getLongitude());
//                item.setArea(sysDept.getArea());
//                item.setDispatchId(sysDept.getDispatchId());
//                item.setUeArea(sysDept.getUeArea());
//            }
//        });
//        return RespJSON.success(data);
////        Integer parentId = Integer.valueOf(req.getParentId());
////        Boolean includeLower = req.getIncludeLower();
////        SysDept evsApiDept = new SysDept();
////        evsApiDept.setParentId(parentId);
////        evsApiDept.setIncludeLower(includeLower==null?false:includeLower);
////        List<SysDept> deptPointVOS = JSONArray.parseArray(JSONObject.toJSONString(evsHttpService.getDepartmentsJson(evsApiDept, evsHttpService.getToken())), SysDept.class);
////        if(CollectionUtils.isEmpty(deptPointVOS)){
////            return RespJSON.success(deptPointVOS);
////        }
////        for (SysDept datum : deptPointVOS) {
////            JSONObject points = evsHttpService.getPoints(evsHttpService.getToken(), 1, 1, datum.getId().intValue());
////            SysDeptVideo sysDeptVideo = new SysDeptVideo();
////            sysDeptVideo.setDeptId(datum.getId());
////            sysDeptVideo.setIsShow(true);
////            List<SysDeptVideo> list = sysDeptVideoService.getList(sysDeptVideo);
////            SysDept sysDept = deptService.getOneById(datum.getId());
////            if(!ObjectUtils.isEmpty(sysDept)){
////                datum.setPoiName(sysDept.getPoiName());
////                datum.setPoiId(sysDept.getPoiId());
////                datum.setDeptType(sysDept.getDeptType());
////                datum.setDescribes(sysDept.getDescribes());
////                datum.setLatitude(sysDept.getLatitude());
////                datum.setLongitude(sysDept.getLongitude());
////                datum.setVideolist(list);
////            }
////            if(CollectionUtils.isEmpty(points.getJSONArray("data"))){
////                datum.setCheckPoint(false);
////            }else {
////                datum.setCheckPoint(true);
////            }
////        }
////        return RespJSON.success(deptPointVOS);
//    }
//
//    /**
//     * 获取点位列表
//     * @param pageSize
//     * @param pageNo
//     * @param deptId
//     * @return
//     */
//    @ResponseBody
//    @GetMapping("/getPointList")
//    public RespJSON getDeptTree(Integer pageSize, Integer pageNo,Integer deptId){
//        return RespJSON.success(evsHttpService.getPoints( evsHttpService.getToken(), pageSize, pageNo, deptId,null,null));
//    }
//
//
//    /**
//     * 根据点位id获取播放链接
//     * @param pointId
//     * @param protocol
//     * @return
//     */
//    @ResponseBody
//    @GetMapping("/{pointId}/signed_url")
//    public RespJSON signedUrl(@PathVariable Integer pointId,String protocol){
//        return RespJSON.success(evsHttpService.pointsSignedUrl( evsHttpService.getToken(), pointId,protocol));
//    }
//
//    /**
//     * 查询大屏需弹窗工单
//     *
//     * @return RespJSON
//     */
//    @GetMapping("/getReminderOrder/{type}")
//    public RespJSON getReminderOrder(@PathVariable Integer type,String protocol) {
//        EnumBigScreen bigScreen = EnumBigScreen.getByCode(type);
//        if(ObjectUtils.isEmpty(bigScreen)){
//            return RespJSON.success();
//        }
//        String json=(String) redisTemplate.opsForList().rightPop(bigScreen.getValue());
//        if(StringUtils.isEmpty(json)){
//            return RespJSON.success();
//        }
//        WorkOrderInfo workOrderInfo = com.alibaba.fastjson.JSONObject.parseObject(json, WorkOrderInfo.class);
//        if(!StringUtils.isEmpty(protocol)){
//            JSONObject jsonObject = evsHttpService.pointsSignedUrl(evsHttpService.getToken(), workOrderInfo.getDeviceId().intValue(), protocol);
//            workOrderInfo.setUrls(jsonObject.toJSONString());
//        }
//        return RespJSON.success(workOrderInfo);
//    }
//
//    /**
//     * 分页查询
//     *
//     * @param workOrderInfoReq workOrderInfoReq
//     * @return RespJSON
//     */
//    @PostMapping  ("/getOrderPageList")
//    public RespJSON getPageList(@RequestBody(required = false) WorkOrderInfo workOrderInfoReq) {
//        if(workOrderInfoReq.getOrderStatus()!=null&&workOrderInfoReq.getOrderStatus()==-1){
//            workOrderInfoReq.setSearchUndone(true);
//            workOrderInfoReq.setOrderStatus(null);
//        }
//        int count = workOrderInfoService.getCount(workOrderInfoReq);
//        List<WorkOrderInfo> list = new ArrayList<>();
//        if (count > 0) {
//            list = workOrderInfoService.getPageList(workOrderInfoReq).stream().peek(item ->{
//                WorkOrderProcess processWhere = new WorkOrderProcess();
//                processWhere.setOrderId(item.getId());
//                item.setProcessList(workOrderProcessService.getList(processWhere));
//                WorkOrderReview reviewWhere = new WorkOrderReview();
//                reviewWhere.setOrderId(item.getId());
//                OrderPhotoLib orderPhotoLib = new OrderPhotoLib();
//                orderPhotoLib.setOrderId(item.getId());
//                List<OrderPhotoLib> photoLibs = orderPhotoLibService.getList(orderPhotoLib);
//                item.setPhotoLibs(photoLibs);
//                item.setReviewList(workOrderReviewService.getList(reviewWhere));
//            }).collect(Collectors.toList());
//        }
//        PageResult result = new PageResult(workOrderInfoReq.getPageNo(), workOrderInfoReq.getPageSize(), count, list);
//        return RespJSON.success(result);
//    }
//
//    /**
//     * 已接单工单
//     * @param ids
//     * @return RespJSON
//     */
//    @GetMapping("/receivedOrder")
//    public RespJSON receivedOrder(String ids) {
//        WJAssert.notNull(ids, "ID 不合法");
//        String[] split = ids.split(",");
//        ArrayList<Long> longs = new ArrayList<>();
//        for (String s : split) {
//            WorkOrderInfo orderInfo = workOrderInfoService.getOneById(Long.valueOf(s));
//            if(orderInfo!=null&&orderInfo.getOrderStatus()!=0){
//                longs.add(orderInfo.getId());
//            }
//        }
//        return RespJSON.success(longs);
//    }
//
//    /**
//     * 调度中心或区域下有多少个场站和营业厅，每个营业厅又有多少个报警
//     * @param sysDept notice
//     * @return RespJSON
//     */
//    @PostMapping("/centerAlarms")
//    public RespJSON numberOfSubordinateAlarms(@RequestBody SysDept sysDept) {
//        SysDept evsApiDept = new SysDept();
//        evsApiDept.setIncludeLower(true);
//        evsApiDept.setParentId(-1);
//        List<SysDept> departments = evsHttpService.getDepartments(evsApiDept, evsHttpService.getToken());
//        List<SysDept> list = new ArrayList<>();
//        if(!StringUtils.isEmpty(sysDept.getArea())){
//            //如果区域不为空，则按区域查询
//            list = sysDeptService.getList(sysDept);
//        }else {
//            //按调度中心查询
//            WJAssert.notNull(sysDept.getDispatchId(), "参数不合法");
//            list = sysDeptService.getList(sysDept);
//        }
//        ArrayList<CenterAlarmsVO> centerAlarmsVOS = new ArrayList<>();
//        for (SysDept dept : list) {
//            Optional<SysDept> first = departments.stream()
//                    .filter(de -> de.getId().equals(dept.getId()))
//                    .findFirst();
//            if(first.isPresent()){
//                dept.setName(first.get().getName());
//            }
//            WorkOrderInfo orderWhere = new WorkOrderInfo();
//            orderWhere.setCreateTimeStart(sysDept.getCreateTimeStart());
//            orderWhere.setUpdateTimeEnd(sysDept.getUpdateTimeEnd());
//            orderWhere.setDeptId(dept.getId());
//            CenterAlarmsVO vo=new CenterAlarmsVO(dept.getId(),dept.getName(),dept.getPoiId(),Long.valueOf(workOrderInfoService.getCount(orderWhere)),dept.getLongitude(),dept.getLatitude(),dept.getPoiName());
//            centerAlarmsVOS.add(vo);
//        }
//        return RespJSON.success(centerAlarmsVOS);
//    }
//
//    /**
//     * 场站告警数量 摄像头分布
//     * @param sysDeptCamera
//     * @return
//     */
//    @PostMapping ("/alarmsOrCamera")
//    public RespJSON alarmsOrCamera(@RequestBody SysDeptCamera sysDeptCamera) {
//        WJAssert.notNull(sysDeptCamera.getDepId(), "参数不合法!");
//        SysCarmera camera = new SysCarmera();
//        camera.setDepId(sysDeptCamera.getDepId());
//        List<SysCarmera> deptCarmeras = sysCarmeraService.getList(camera);
//        JSONObject points = evsHttpService.getPoints(evsHttpService.getToken(), 80, 1, sysDeptCamera.getDepId().intValue(),null,null);
//        List<SysCarmera> carmeras = JSONArray.parseArray(points.getString("data"), SysCarmera.class);
//        List<SysCarmera> list = carmeras.stream().peek(item->{
//            WorkOrderInfo workOrderInfo = new WorkOrderInfo();
//            workOrderInfo.setOrderStatus(EnumWorkOrderStatus.AGENCY.getCode());
//            workOrderInfo.setDeptId(item.getDepId());
//            workOrderInfo.setPageSize(1);
//            workOrderInfo.setPageNo(1);
//            workOrderInfo.setDeviceId(item.getId());
//            workOrderInfo.setCreateTimeStart(sysDeptCamera.getCreateTimeStart());
//            workOrderInfo.setUpdateTimeEnd(sysDeptCamera.getUpdateTimeEnd());
//            List<WorkOrderInfo> pageList = workOrderInfoService.getPageList(workOrderInfo);
//            if(!StringUtils.isEmpty(sysDeptCamera.getCodingType())){
//                JSONObject jsonObject = evsHttpService.pointsSignedUrl(evsHttpService.getToken(), item.getPointId().intValue(), sysDeptCamera.getCodingType());
//                item.setUrls(jsonObject.toJSONString());
//            }
//            item.setWorkOrderInfo(CollectionUtils.isEmpty(pageList)?null:pageList.get(0));
//            Optional<SysCarmera> first = carmeras.stream()
//                    .filter(de -> de.getPointId().equals(item.getPointId()))
//                    .findFirst();
//            if(first.isPresent()){
//                item.setPointStatus(first.get().getPointStatus());
//                item.setOnline(first.get().getPointStatus().equals("ONLINE"));
//                item.setPointName(first.get().getPointName());
//            }
//            Optional<SysCarmera> first1 = deptCarmeras.stream()
//                    .filter(de -> de.getId().equals(item.getPointId()))
//                    .findFirst();
//            if(first.isPresent()){
//                item.setCameraPoiId(first1.get().getCameraPoiId());
//            }
//            WorkOrderInfo orderInfo = new WorkOrderInfo();
//            orderInfo.setDeviceId(item.getId());
//            orderInfo.setCreateTimeStart(sysDeptCamera.getCreateTimeStart());
//            orderInfo.setUpdateTimeEnd(sysDeptCamera.getUpdateTimeEnd());
//            item.setAlarmsCount(workOrderInfoService.getCount(orderInfo));
//        }).collect(Collectors.toList());
//        WorkOrderInfo orderInfo = new WorkOrderInfo();
//        orderInfo.setDeptId(sysDeptCamera.getDepId());
//        orderInfo.setCreateTimeStart(sysDeptCamera.getCreateTimeStart());
//        orderInfo.setUpdateTimeEnd(sysDeptCamera.getUpdateTimeEnd());
//        return RespJSON.success(new AlarmsOrCameraVO(workOrderInfoService.getCount(orderInfo),list));
//    }
//
//    /**
//     * 催单
//     * @param notice notice
//     * @return RespJSON
//     */
//    @PostMapping("/reminders")
//    public RespJSON reminders(@RequestBody SysNotice notice) {
//        WJAssert.notNull(notice.getId(), "ID 不合法");
//        workOrderInfoService.reminders(notice.getId(), "大屏系统",-1L);
//        return RespJSON.success();
//    }
//
//    /**
//     * 获取部门详情 视频资源等
//     * @param id
//     * @return
//     */
//    @GetMapping("/getDeptInfo")
//    public RespJSON getDeptInfo(Long id){
//        SysDept deptServiceOneById = sysDeptService.getOneById(id);
//        if(deptServiceOneById==null){
//            //往上级找视频资源
//            SysDept sysDept = new SysDept();
//            sysDept.setId(id);
//            sysDept.setIncludeLower(true);
//            List<SysDept> departments = evsHttpService.getDepartments(sysDept, evsHttpService.getToken());
//            List<SysDeptVideo> videoUrl = getVideoUrl(departments, id);
//            SysDept video = new SysDept();
//            video.setVideolist(videoUrl);
//            return RespJSON.success(video);
//        }
//        SysDeptVideo sysDeptVideo = new SysDeptVideo();
//        sysDeptVideo.setDeptId(deptServiceOneById.getId());
//        sysDeptVideo.setIsShow(true);
//        deptServiceOneById.setVideolist(sysDeptVideoService.getList(sysDeptVideo));
//        if(CollectionUtils.isEmpty(deptServiceOneById.getVideolist())){
//            SysDept sysDept = new SysDept();
//            sysDept.setId(id);
//            sysDept.setIncludeLower(true);
//            List<SysDept> departments = evsHttpService.getDepartments(sysDept, evsHttpService.getToken());
//            List<SysDeptVideo> videoUrl = getVideoUrl(departments, id);
//            deptServiceOneById.setVideolist(videoUrl);
//        }
//        return RespJSON.success(deptServiceOneById);
//    }
//    private List<SysDeptVideo> getVideoUrl(List<SysDept> list,Long id){
//        Optional<SysDept> result = list.stream()
//                .filter(dept -> dept.getId().equals(id))
//                .findFirst();
//        SysDept sysDept = result.get();
//        SysDept deptServiceOneById = sysDeptService.getOneById(Long.valueOf(sysDept.getParentId()));
//        if(deptServiceOneById == null){
//            if(sysDept.getParentId()==-1){
//                return null;
//            }
//            return getVideoUrl(list, Long.valueOf(sysDept.getParentId()));
//        }else{
//            SysDeptVideo sysDeptVideo = new SysDeptVideo();
//            sysDeptVideo.setDeptId(deptServiceOneById.getId());
//            sysDeptVideo.setIsShow(true);
//            List<SysDeptVideo> videos = sysDeptVideoService.getList(sysDeptVideo);
//            if(CollectionUtils.isEmpty(videos)){
//                if(sysDept.getParentId()==-1){
//                    return null;
//                }
//                return getVideoUrl(list, Long.valueOf(sysDept.getParentId()));
//            }else {
//                return videos;
//            }
//        }
//    }
//
//
//
//    @PostMapping("/businessOverview")
//    public RespJSON businessOverview(@RequestBody SysDept sysDept){
//        BusinessOverbiewVO businessOverbiewVO = new BusinessOverbiewVO();
//        //如果区域不为空，则按区域查询
//        if(!StringUtils.isEmpty(sysDept.getArea())){
//            List<SysDept> list = sysDeptService.getList(sysDept);
//            extractedArea(businessOverbiewVO,list,sysDept.getArea());
//            return RespJSON.success(businessOverbiewVO);
//        }
//        List<SysDept> list = sysDeptService.getList(new SysDept());
//        //如果没有参数 查询所有部门业务概况
//        if(ObjectUtils.isEmpty(sysDept.getId())){
//            extracted(businessOverbiewVO, list,false,null,false);
//            Object officeAiNum = redisTemplate.opsForValue().get(RedisKeys.ALL_AI_NUM);
//            SysCarmera sysDeptCameraEq = new SysCarmera();
//            sysDeptCameraEq.setDepType(EnumDeptType.DEPT_BUSINESS_HALL.getCode());
//            sysDeptCameraEq.setOnline(true);
//            sysDeptCameraEq.setIsAi(true);
//            businessOverbiewVO.setOfficeAiOnLineCameraNum(Long.valueOf(sysCarmeraService.getCount(sysDeptCameraEq)));
//            sysDeptCameraEq.setDepType(EnumDeptType.DEPT_STATIONS.getCode());
//            businessOverbiewVO.setSiteAiOnLineCameraNum(Long.valueOf(sysCarmeraService.getCount(sysDeptCameraEq)));
//            businessOverbiewVO.setAiNum(officeAiNum==null?0L:Long.valueOf(officeAiNum.toString()));
//            Object o = redisTemplate.opsForValue().get(RedisKeys.AI_NUMS);
//            businessOverbiewVO.setAiCameraRoadNum(o==null?0:Integer.valueOf(o.toString()));
//            return RespJSON.success(businessOverbiewVO);
//        }
//        WJAssert.notNull(sysDept.getId());
//        SysDept dept = sysDeptService.getOneById(sysDept.getId());
//        if(ObjectUtils.isEmpty(dept)){
//            return RespJSON.success();
//        }
//        businessOverbiewVO.setSiteArea(dept.getSiteArea());
//        businessOverbiewVO.setModel(dept.getIsModel());
//        businessOverbiewVO.setModelName(dept.getModelName());
//        //如果是调度中心
//        if(dept.getDeptType().equals(EnumDeptType.DEPT_DISPATCH_CENTER.getCode())){
//            extracted(businessOverbiewVO, list,true,dept.getId(),false);
////            Object aiNum = redisTemplate.opsForValue().get(RedisKeys.DISPATCH_AI_NUM+":"+dept.getId());
////            businessOverbiewVO.setAiNum(aiNum==null?0L:Long.valueOf(aiNum.toString()));
//            businessOverbiewVO.setAiNum(businessOverbiewVO.getOfficeAiNum()+ businessOverbiewVO.getSiteAiNum());
//            Object o = redisTemplate.opsForValue().get(RedisKeys.AI_NUMS+":"+dept.getId());
//            businessOverbiewVO.setAiCameraRoadNum(o==null?0:Integer.valueOf(o.toString()));
//            return RespJSON.success(businessOverbiewVO);
//        }
//        //如果是公司
//        if(dept.getDeptType().equals(EnumDeptType.DEPT_SUBSIDIARY.getCode())){
//            extracted(businessOverbiewVO, list,false,dept.getId(),true);
////            Object aiNum = redisTemplate.opsForValue().get(RedisKeys.COMPANY_AI_NUM+":"+dept.getId());
////            businessOverbiewVO.setAiNum(aiNum==null?0L:Long.valueOf(aiNum.toString()));
//            businessOverbiewVO.setAiNum(businessOverbiewVO.getOfficeAiNum()+ businessOverbiewVO.getSiteAiNum());
//            Object o = redisTemplate.opsForValue().get(RedisKeys.AI_NUMS+":"+dept.getId());
//            businessOverbiewVO.setAiCameraRoadNum(o==null?0:Integer.valueOf(o.toString()));
//            return RespJSON.success(businessOverbiewVO);
//        }
//        //如果是营业厅
//        if(dept.getDeptType().equals(EnumDeptType.DEPT_BUSINESS_HALL.getCode())){
//            businessOverbiewVO.setOfficeCameraNum(Long.valueOf(dept.getCameraCount()==null?0L:dept.getCameraCount()));
//            businessOverbiewVO.setOfficeAiCameraNum(Long.valueOf(dept.getAiCameraCount()==null?0L:dept.getAiCameraCount()));
//            return getRespJSON(businessOverbiewVO, dept);
//        }
//        //如果是场站
//        if(dept.getDeptType().equals(EnumDeptType.DEPT_STATIONS.getCode())){
//            businessOverbiewVO.setSiteCameraNum(Long.valueOf(dept.getCameraCount()==null?0L:dept.getCameraCount()));
//            businessOverbiewVO.setSiteAiCameraNum(Long.valueOf(dept.getAiCameraCount()==null?0L:dept.getAiCameraCount()));
//            return getRespJSON(businessOverbiewVO, dept);
//        }
//        return RespJSON.success();
//    }
//
//    private RespJSON getRespJSON(BusinessOverbiewVO businessOverbiewVO, SysDept dept) {
//        SysCarmera sysDeptCamera = new SysCarmera();
//        sysDeptCamera.setDepId(dept.getId());
//        List<SysCarmera> deptCameras = sysCarmeraService.getList(sysDeptCamera);
//        Long offlineNum=0L;
//        Long onlineNum=0L;
//        for (SysCarmera deptCamera : deptCameras) {
//            if(deptCamera.getOnline()){
//                onlineNum=onlineNum+1;
//            }else {
//                offlineNum=offlineNum+1;
//            }
//        }
//        businessOverbiewVO.setOfflineCameraNum(offlineNum);
//        businessOverbiewVO.setOnlineCameraNum(onlineNum);
//        return RespJSON.success(businessOverbiewVO);
//    }
//
//    private void extractedArea(BusinessOverbiewVO businessOverbiewVO, List<SysDept> list,String area) {
//        List<SysDept> sites = list.stream().filter(item -> item.getDeptType().equals(EnumDeptType.DEPT_STATIONS.getCode())).collect(Collectors.toList());
//        List<SysDept> offices = list.stream().filter(item -> item.getDeptType().equals(EnumDeptType.DEPT_BUSINESS_HALL.getCode())).collect(Collectors.toList());
//        Long officeCamerNum=0L;
//        Long officeAiCamerNum=0L;
//        Long siteCamerNum=0L;
//        Long siteAiCamerNum=0L;
//        //营业厅数量
//        businessOverbiewVO.setOfficeNum(Long.valueOf(offices.size()));
//        for (SysDept office : offices) {
//            officeCamerNum=officeCamerNum+(office.getCameraCount()==null?0L:office.getCameraCount());
//            officeAiCamerNum=officeAiCamerNum+(office.getAiCameraCount()==null?0L:office.getAiCameraCount());
//        }
//        //营业厅摄像头数量
//        businessOverbiewVO.setOfficeCameraNum(officeCamerNum);
//        //营业厅AI摄像头数量
//        businessOverbiewVO.setOfficeAiCameraNum(officeAiCamerNum);
//        //场站数量
//        businessOverbiewVO.setSiteNum(Long.valueOf(sites.size()));
//        for (SysDept site : sites) {
//            siteCamerNum=siteCamerNum+(site.getCameraCount()==null?0L:site.getCameraCount());
//            siteAiCamerNum=siteAiCamerNum+(site.getAiCameraCount()==null?0L:site.getAiCameraCount());
//        }
//        //场站AI摄像头数量
//        businessOverbiewVO.setSiteAiCameraNum(siteAiCamerNum);
//        //场站摄像头数量
//        businessOverbiewVO.setSiteCameraNum(siteCamerNum);
//        if(area.equals("四川")){
//            Object aiNum = redisTemplate.opsForValue().get(RedisKeys.AREA_AI_NUM_SC);
//            businessOverbiewVO.setAiNum(aiNum==null?0L:Long.valueOf(aiNum.toString()));
//            Object siteAiNum = redisTemplate.opsForValue().get(RedisKeys.AREA_AI_NUM_SC_SITE);
//            businessOverbiewVO.setSiteAiNum(siteAiNum==null?0L:Long.valueOf(siteAiNum.toString()));
//            Object officeAiNum = redisTemplate.opsForValue().get(RedisKeys.AREA_AI_NUM_SC_BUSINESS);
//            businessOverbiewVO.setOfficeAiNum(officeAiNum==null?0L:Long.valueOf(officeAiNum.toString()));
//        }
//        if(area.equals("顺平")){
//            Object aiNum = redisTemplate.opsForValue().get(RedisKeys.AREA_AI_NUM_SP);
//            businessOverbiewVO.setAiNum(aiNum==null?0L:Long.valueOf(aiNum.toString()));
//            Object siteAiNum = redisTemplate.opsForValue().get(RedisKeys.AREA_AI_NUM_SP_SITE);
//            businessOverbiewVO.setSiteAiNum(siteAiNum==null?0L:Long.valueOf(siteAiNum.toString()));
//            Object officeAiNum = redisTemplate.opsForValue().get(RedisKeys.AREA_AI_NUM_SP_BUSINESS);
//            businessOverbiewVO.setOfficeAiNum(officeAiNum==null?0L:Long.valueOf(officeAiNum.toString()));
//        }
//        if(area.equals("景德镇")){
//            Object aiNum = redisTemplate.opsForValue().get(RedisKeys.AREA_AI_NUM_JDZ);
//            businessOverbiewVO.setAiNum(aiNum==null?0L:Long.valueOf(aiNum.toString()));
//            Object siteAiNum = redisTemplate.opsForValue().get(RedisKeys.AREA_AI_NUM_JDZ_SITE);
//            businessOverbiewVO.setSiteAiNum(siteAiNum==null?0L:Long.valueOf(siteAiNum.toString()));
//            Object officeAiNum = redisTemplate.opsForValue().get(RedisKeys.AREA_AI_NUM_JDZ_BUSINESS);
//            businessOverbiewVO.setOfficeAiNum(officeAiNum==null?0L:Long.valueOf(officeAiNum.toString()));
//        }
//        if(area.equals("安徽")){
//            Object aiNum = redisTemplate.opsForValue().get(RedisKeys.AREA_AI_NUM_AH);
//            businessOverbiewVO.setAiNum(aiNum==null?0L:Long.valueOf(aiNum.toString()));
//            Object siteAiNum = redisTemplate.opsForValue().get(RedisKeys.AREA_AI_NUM_AH_SITE);
//            businessOverbiewVO.setSiteAiNum(siteAiNum==null?0L:Long.valueOf(siteAiNum.toString()));
//            Object officeAiNum = redisTemplate.opsForValue().get(RedisKeys.AREA_AI_NUM_AH_BUSINESS);
//            businessOverbiewVO.setOfficeAiNum(officeAiNum==null?0L:Long.valueOf(officeAiNum.toString()));
//        }
//    }
//    private void extracted(BusinessOverbiewVO businessOverbiewVO, List<SysDept> list, Boolean isDispatch,Long dispatchId,Boolean isCompany) {
//        List<SysDept> sites ;
//        List<SysDept> offices;
//        if(isDispatch){
//            sites = list.stream().filter(item -> item.getDeptType() != null && item.getDeptType().equals(EnumDeptType.DEPT_STATIONS.getCode()) && item.getDispatchId() != null && item.getDispatchId().equals(dispatchId)).collect(Collectors.toList());
//            offices = list.stream().filter(item -> item.getDeptType() != null && item.getDeptType().equals(EnumDeptType.DEPT_BUSINESS_HALL.getCode())&& item.getDispatchId() != null && item.getDispatchId().equals(dispatchId)).collect(Collectors.toList());
//        }else if(isCompany){
//            sites = list.stream().filter(item -> item.getDeptType() != null && item.getDeptType().equals(EnumDeptType.DEPT_STATIONS.getCode()) && item.getCompanyId() != null && item.getCompanyId().equals(dispatchId)).collect(Collectors.toList());
//            offices = list.stream().filter(item -> item.getDeptType() != null && item.getDeptType().equals(EnumDeptType.DEPT_BUSINESS_HALL.getCode())&& item.getCompanyId() != null && item.getCompanyId().equals(dispatchId)).collect(Collectors.toList());
//        } else {
//            sites = list.stream().filter(item -> item.getDeptType() != null && item.getDeptType().equals(EnumDeptType.DEPT_STATIONS.getCode()) ).collect(Collectors.toList());
//            offices = list.stream().filter(item -> item.getDeptType() != null && item.getDeptType().equals(EnumDeptType.DEPT_BUSINESS_HALL.getCode())).collect(Collectors.toList());
//        }
//        Long officeCamerNum=0L;
//        Long officeAiCamerNum=0L;
//        Long siteCamerNum=0L;
//        Long siteAiCamerNum=0L;
//        //营业厅数量
//        businessOverbiewVO.setOfficeNum(Long.valueOf(offices.size()));
//        for (SysDept office : offices) {
//            officeCamerNum=officeCamerNum+(office.getCameraCount()==null?0L:office.getCameraCount());
//            officeAiCamerNum=officeAiCamerNum+(office.getAiCameraCount()==null?0L:office.getAiCameraCount());
//        }
//        //营业厅摄像头数量
//        businessOverbiewVO.setOfficeCameraNum(officeCamerNum);
//        //营业厅AI摄像头数量
//        businessOverbiewVO.setOfficeAiCameraNum(officeAiCamerNum);
//        //场站数量
//        businessOverbiewVO.setSiteNum(Long.valueOf(sites.size()));
//        for (SysDept site : sites) {
//            siteCamerNum=siteCamerNum+(site.getCameraCount()==null?0L:site.getCameraCount());
//            siteAiCamerNum=siteAiCamerNum+(site.getAiCameraCount()==null?0L:site.getAiCameraCount());
//        }
//        //场站AI摄像头数量
//        businessOverbiewVO.setSiteAiCameraNum(siteAiCamerNum);
//        //场站摄像头数量
//        businessOverbiewVO.setSiteCameraNum(siteCamerNum);
//        if(isDispatch){
//            Object siteAiNum = redisTemplate.opsForValue().get(RedisKeys.DISPATCH_STATIONS_AI_NUM + ":" + dispatchId);
//            Object officeAiNum = redisTemplate.opsForValue().get(RedisKeys.DISPATCH_OFFICES_AI_NUM + ":" + dispatchId);
//            businessOverbiewVO.setSiteAiNum(siteAiNum==null?0L:Long.valueOf(siteAiNum.toString()));
//            businessOverbiewVO.setOfficeAiNum( officeAiNum==null?0L:Long.valueOf(officeAiNum.toString()));
//        }else if(isCompany) {
//            //总数场站AI算法种类
//            Object siteAiNum = redisTemplate.opsForValue().get(RedisKeys.COMPANY_STATIONS_AI_NUM+":" + dispatchId);
//            businessOverbiewVO.setSiteAiNum(siteAiNum==null?0L:Long.valueOf(siteAiNum.toString()));
//            //总数营业厅AI算法种类
//            Object officeAiNum = redisTemplate.opsForValue().get(RedisKeys.COMPANY_OFFICES_AI_NUM+":" + dispatchId);
//            businessOverbiewVO.setOfficeAiNum( officeAiNum==null?0L:Long.valueOf(officeAiNum.toString()));
//        }else {
//            //总数场站AI算法种类
//            Object siteAiNum = redisTemplate.opsForValue().get(RedisKeys.STATIONS_NUM);
//            businessOverbiewVO.setSiteAiNum(siteAiNum==null?0L:Long.valueOf(siteAiNum.toString()));
//            //总数营业厅AI算法种类
//            Object officeAiNum = redisTemplate.opsForValue().get(RedisKeys.OFFICES_NUM);
//            businessOverbiewVO.setOfficeAiNum( officeAiNum==null?0L:Long.valueOf(officeAiNum.toString()));
//        }
//    }
//}
